SetAxisCam
Links the axes and starts to cam.
Syntax
KsCommandStatus SetAxisCam(
int Master,
int Slave,
BOOL Permanent,
double MasterOffset,
double SlaveOffset,
double MasterScaling,
double SlaveScaling,
McCamStartMode StartMode,
double StartParameter,
McSource MasterValueSource,
int Cam,
McBufferMode BufferMode
);
Parameters
Master [in]: the index of the master axis. Indexes are zero based. Aliases affect this parameter.
Slave [in]: the index of the slave axis. Indexes are zero based. Aliases affect this parameter. The number of slaves is up to 32.
Permanent [in]: determines whether the cam state is preserved after the motor is disabled.
TRUE: the cam state is preserved even if the motor is disabled. For example, if the master axis is enabled, the slave axis will be enabled. If an error has occurred on the master, it occurred on the slave too.
FALSE: the cam state won't be preserved after the motor is disabled.
MasterOffset [in]: the offset to the positions of the master axis in the cam table.
SlaveOffset [in]: the offset to the positions of the slave axis in the cam table.
MasterScaling [in]: the factor for the master profile (default = 1.0). From the slave point of view the overall master profile is multiplied by this factor.
SlaveScaling [in]: the factor for the slave profile (default = 1.0). The overall slave profile is multiplied by this factor.
StartMode [in]: the cam mode your axes use. See the McCamStartMode type.
StartParameter [in]: depends on the start ramp you choose. If it is camRampDistance
, StartParameter is the distance the slave moves. The unit is count. If it is camRampTime
, StartParameter is the time the slaves takes to move. The unit is second. This parameter uses the master's information to determine how to move the slave. The distance is based on how far the master moves.
MasterValueSource [in]: defines the source for synchronization. See the McSource type.
- mcSetValue – synchronization on master set value. We suggest you use these settings.
- mcActualValue – synchronization on master actual value. This setting may not be stable.
- mcSecondEncoderValue – actual value of the secondary encoder of the axis.
NOTE: mcSecondEncoderValue is not supported yet.
Cam [in]: the index of the cam table, linked to the output of SetCamTable.
BufferMode [in]: defines how to blend the velocity of two functions. See the McBufferMode type.
Return value
Returns the KsCommandStatus structure.
Remarks
- For more information about how a cam works, see Concepts > Camming.
- It is not required that the master is stationary.
- If the actual master and slave positions do not correspond to the offset values when SetAxisCam is run, either an error occurs or the system deals with the difference automatically.
- This function is not merged with the SetCamTable, because this separation enables changes on the fly.
- A mechanical analogy to a slave offset is a cam welded with additional constant layer thickness. Because of this, the slave positions have a constant offset and the offset can be interpreted as axis offset of the master shaft, if linear guided slave tappets are assumed.
- To detach the slave axis, use ReleaseAxis.
- SetAxisCam is not affected when modulo axis is enabled. The axis doesn't treat positions in the cam table as modulo positions. For example, assume the master and slave axes are synchronized, and both are configured with a modulo value of 360. The next MasterPosition and SlavePosition in the cam table are set to 360 and 540, respectively. In this case, the master axis will rotate 1 cycle, while the slave axis will rotate 1.5 cycles to reach the configured position. After enabling modulo axis, we recommend that users:
- Use SetAxisPositionOffset to reset the position, preventing discrepancies between the displayed and internal positions. For example, when the modulo axis value is set to 360, the user might see a position of 0, while the internal position is 360000.
- Use velocity or distance APIs to move master axis.
Example
KsCommandStatus AssignCamSlave(INT Master, INT Slave, INT Table) {
BOOL InSync = FALSE;
BOOL Busy = FALSE;
BOOL Active = FALSE;
BOOL CommandAborted = FALSE;
BOOL Error = FALSE;
WORD ErrorId = 0;
INT QueueIndex = -1;
BOOL EndOfProfile = FALSE;
KsCommandStatus cam = SetAxisCam(Master, Slave, FALSE,
0, //Master Offset. Offset to add to the master positions in the CAM table
0, //Slave Offset. Offset to add to the slave positions in the CAM table
1, /*Master Scaling. Ratio to apply to the distance between
the master positions and the original position*/
1, //Slave Scaling. Ratio to apply to the slave positions in the CAM table
camRelative, //StartMode.
/*Absolute: The slave axis will jump to its target in the table.
Alarms may be triggered if the position is too far.*/
//Relative: The current master/slave positions are used as origin for the CAM table.
/*Ramp Distance: The slave axis will ramp to its target position
while the master axis moves along the distance provided in StartParameter*/
/*Ramp Time: The slave axis will ramp to its target position
over the period of time provided in seconds in StartParameter*/
0, //Start Parameter
mcSetValue, /*Master Value Source. Value of the master position used.
Cam be the target position (commanded value and set value are identical)
or the actual position.*/
Table,
mcAborting
);
return cam;
}
Requirements
RT | Win32 | |
---|---|---|
Minimum supported version | 4.0 | 4.0 |
Header | ksmotion.h | ksmotion.h |
Library | KsApi_Rtss.lib | KsApi.lib |
See also